package com.zfh.test;

import com.zfh.iterator.Book;
import com.zfh.iterator.BookShelf;
import com.zfh.iterator.Iterator;

public class Main {

	public static void main(String[] args) {

		// 初始化书架
		BookShelf bookShelf = new BookShelf(4);
		// 添加4本书到书架
		bookShelf.appendBook(new Book("JAVA企业级应用开发"));
		bookShelf.appendBook(new Book("python企业级应用开发"));
		bookShelf.appendBook(new Book("cpp企业级应用开发"));
		bookShelf.appendBook(new Book("golang企业级应用开发"));
		// 获得迭代器
		Iterator it = bookShelf.iterator();
		// 一次迭代遍历，迭代查看每本书书名
		int i=0;
		while (it.hasNext()) {
			Book book = (Book) it.next();
			i++;
			System.out.println("这是书架上的第"+i+"本书："+book.getName());
		}
	}

}
